<?php

namespace app\common\model;
use think\Db;
/**
 * [Act  寺院项目表]
 * @author [C。]
 * @return html
 */
class Act extends Base
{
    protected $name = 'acts';

    /**
     * 获取项目列表信息
     */
    public function getActByConditon($map, $from = 0, $size = 5)
    {
        $order = ['a.id' => 'desc'];

        $join = [
            ['app_company c','c.id = a.comid'],
        ];

        $result =  $this->field('a.id,a.title,a.cover,a.amount,a.addtime,a.states,c.comname,a.deltime,a.content,a.aptitude,a.feedback')
            ->alias('a')
            ->join($join)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();

        return $result;
    }
    /**
     * 根据条件来获取列表的数据的总数
     * @param array $param
     */
    public function getActCountByCondition($map = []) {
        $join = [
            ['app_company c','c.id = a.comid'],
        ];

        $result =  $this->alias('a')
            ->join($join)
            ->where($map)
            ->count();

        return $result;
    }
    /**
     * [findNewData  查找最新一条数据]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function findNewData($id = '',$id_name = 'id',$field = '*')
    {
        $order = ['id' => 'desc'];
        return  $this->field($field)->where($id_name, $id)->order($order)->find();
    }
    /**
     * [getlist  获取分页列表]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function getlist($map, $from = 0, $size = 5,$field='*')
    {
        $order = ['states' => 'asc','id' => 'desc'];
        return  $this->field($field)->where($map)->limit($from, $size)->order($order)->select();
    }
    /**
     * [getCount  获取总数]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function getCount($map)
    {
        return  $this->where($map)->count();
    }
}
